clearvars -except Globaloption option

%% Baseline Results
data = readtable('../../data/main_VAR/US_full.xlsx');
date = data.year;

startdatenum = 1793;
enddatenum = 2020;

startdate = find(date == startdatenum);
enddate = find(date == enddatenum);
T_post = length(date(startdate:enddate));

Tstart = startdate; 
Tend = enddate; 
T = Tend - Tstart + 1;

date = date(startdate:enddate);

data = data((data.year >= startdatenum - 1), :);
data = data((data.year <= enddatenum), :);

taxrevgdp = data.tau(2:end); % government tax revenue to GDP ratio
taxrevgdp0 = data.tau(1); % government tax revenue to GDP ratio
spendgdp = data.g(2:end); % government spending before interest exdp. to GDP ratio
spendgdp0 = data.g(1); % government spending before interest exp. to GDP ratio
surplusgdp = taxrevgdp - spendgdp; % primary surplus to gdp

%% Saving parameter estimates to automatically update the paper
fID = fopen('../../results/tables_main/US/full/Table_US_sumstats.tex', 'w');

fprintf(fID, '\\newcommand{\\USmeansurplusgdppct_preWWI}{%4.2f}\n', 100 * mean(surplusgdp(1:find(date == 1913))));

fprintf(fID, '\\newcommand{\\USmeansurplusgdppct_preWWII}{%4.2f}\n', 100 * mean(surplusgdp(1:find(date == 1946))));

%% Close File
fclose(fID);
